import Vue from 'vue'
import VueRouter from 'vue-router'

const req = require.context('@/router/modules',false, /\.js$/)
const requireAll = requireContext => {
    return requireContext.keys().map(requireContext);
}
var arr = []
requireAll(req).forEach(item => {
  console.log(item);
  arr = [...arr,...item.default]
})
Vue.use(VueRouter)

const routes = [
  ...arr
]

const router = new VueRouter({
  routes
})

router.beforeEach((to,from,next)=>{
  document.title = to.meta.title
  next()
})

export default router
